
const UserModel = require('../model/user')
const formidable = require('formidable');
const path = require("path")


exports.register = (req, res) => {
    UserModel.Register(req.body, (err, data) => {
        if (err) res.send({ "code": 500, "message": "服务器异常" })
        res.send(data)
    })
}

exports.login = (req, res) => {
    UserModel.Login(req.body, (err, data) => {
        if (err) res.send({ "code": 500, "message": "服务器异常" })
        else if (data.code == 0) {
            req.session.username = req.body.username
            data.data = req.session.username
            res.send(data)
        } else {
            res.send(data)
        }
    })
}

exports.getUserInfo = (req, res) => {
    UserModel.getUserInfo(req.body, (err, data) => {
        if (err) res.send({ "code": 500, "message": "服务器异常" })
        res.send(data)
    })
}

